<?php
session_start();
include_once("../../untils/conn.php");
mysqli_query($con, "set names utf8");

// 获取当前正在登录的账号信息的代理
$proxy_acc = $_SESSION["account"];

// 查询revenue表，找到符合条件的数据并输出给前端
$sql = "SELECT * FROM revenue WHERE (account = '$proxy_acc') AND oder_sta = 3 ORDER BY ID DESC";
$result = mysqli_query($con, $sql);
if ($result && mysqli_num_rows($result) > 0) {
    $data = array();
    while ($rows = mysqli_fetch_assoc($result)) {
        $oderid = $rows["oderid"];
        $name = $rows['name'];
        $odersta = $rows['oder_sta'];
        $type = $rows['type'];
        $price = $rows['price'];
        $state = $rows['state'];
        $notes = $rows['beizhu'];
        $crtime = date('Y-m-d H:i:s', $rows['cr_time']);
        $dztime = date('Y-m-d H:i:s', $rows['dz_time']);
        $data[] = array(
            "account" => $rows['account'],
            "oderid" => $oderid,
            "name" => $name,
            "odersta" => $odersta,
            "type" => $type,
            "price" => $price,
            "status" => $state,
            "notes" => $notes,
            "crtime" => $crtime,
            "dztime" => $dztime,
            
        );
    }
    echo json_encode($data);
} else {
    echo json_encode(array("error" => "没有符合条件的数据"));
}
